package com.itheima.homework;

import java.util.ArrayList;

/**
 * @Author 王加鑫
 * @Date 2021/4/28 14:11
 * @Version 1.0
 */
public class List {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("苹果");
        list.add("鸭梨");
        list.add("鸭梨");
        list.add("西瓜");

        for (int i = list.size()-1; i >=0; i--) {
            if(list.get(i).equals("鸭梨")){
                list.remove(i);
            }
        }

        for(String s:list){
            System.out.println(s);
        }
    }
}
